package com.jcwx.game.login;

import com.jcwx.game.common.genenrate.MD5;
import com.jcwx.game.domain.AreaInfo;
import com.jcwx.game.domain.LoginGameInfo;
import com.jcwx.game.domain.LoginPassportInfo;
import com.jcwx.game.domain.RegisterInfo;

/**
 * 
 * @author csp
 *
 */
public class Login {

	// 客户端加密 Key
	private static String verifyKey = "sdafdddoio4ewu7iwi4i3iw2qq2d";
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		
		

		Register register = new Register();
		RegisterInfo registerInfo = register.getRegisterInfo();
		if (registerInfo.getCode().equals(0)) {
			System.out.println("注册成功 ，拿到注册信息");
			// 登录 passport 验证
			LoginPassport loginPassport = new LoginPassport();
			LoginPassportInfo loginPassportInfo = loginPassport
					.LoginPassportInfo(registerInfo);
			if (loginPassportInfo.getCode().equals(0)) {

				System.out.println("通过Passport 成功  拿到 token ");
				GetArea getArea = new GetArea();
				AreaInfo areaInfo = getArea.AreaInfo(registerInfo,loginPassportInfo);

				if (areaInfo.getToken_key() != null
						&& !areaInfo.getToken_key().equals("")) {
					System.out.println("拿到登录  tokeng_key ");
					LoginGame loginGame = new LoginGame();

					LoginGameInfo loginGameInfo = loginGame.loginGameInfo(areaInfo);
					
					if (loginGameInfo.getCode().equals(0)) {
						System.out.println("拿到 游戏登录信息  开始登录游戏  ");
						
						StringBuilder buf = new StringBuilder();
						buf.append(loginGameInfo.getLoginSign().getPtCode()).append(loginGameInfo.getLoginSign().getPtAreaId()).append("")
						.append(loginGameInfo.getLoginSign().getUserName()).append(loginGameInfo.getLoginSign().getTime()).append(verifyKey);
						
						// [139160, , 1401182753250, 43a86799e7a74cacb50abe01066d73ce, 1, 0, wonder, 68, Windows] 
						String decKey=MD5.encrypByMd5(buf.toString());
						System.out.println(decKey);
						

					}
				}
			}
			

		}

	}

}
